const expect = chai.expect;
import Vue from 'vue';
import Popover from '../src/popover';

Vue.config.productionTip = false;
Vue.config.devtools = false;

describe('popover', () => {
  it('存在', () => {
    expect(Popover).to.exist;
  });

  it('可以设置position', (done) => {
    Vue.component('popover', Popover);
    const div = document.createElement('div');
    document.body.appendChild(div);
    div.innerHTML = `
    <popover position="bottom" ref="a">
        <template slot="content">
            弹出内容
        </template>
        <button>点我</button>
    </popover>
    `;

    const vm = new Vue({
      el: div
    });

    vm.$nextTick(() => {
      console.log(vm.$el.outerHTML);
      vm.$el.querySelector('button').click();
      vm.$nextTick(() => {
        console.log(vm.$refs.a.$refs.contentWrapper);
        expect(vm.$refs.a.$refs.contentWrapper.classList.contains('position-bottom')).to.be(true);
        done();
      },500);
    });
  });

  //failed↓
  it('可以设置 trigger', (done) => {
    Vue.component('popover', Popover);
    const div = document.createElement('div');
    document.body.appendChild(div);
    div.innerHTML = `
    <popover position="bottom" ref="a">
        <template slot="content">
            弹出内容
        </template>
        <button>点我</button>
    </popover>
    `;

    const vm = new Vue({
      el: div
    });
    let event = new Event('mouseenter');
    vm.$el.dispatchEvent(event);
    vm.$nextTick(() => {
      expect(vm.$refs.a.$refs.contentWrapper).to.be.exist;
      done();
    },500);
  });

});
